@extends('admin.app')

@section('breadcrumb')
    <div class="bg-light lter b-b wrapper-md">
        <ol class="breadcrumb bg-light lter m-n no-padder">
            <li><a href="{{ admin_action('HomeController@index') }}">主页</a></li>
            <li>业务管理</li>
            <li class="active">用户管理</li>
        </ol>
    </div>
@endsection

@section('content')
    <div class="panel panel-default">
        <div class="panel-heading font-bold">
            用户列表列表
        </div>
        <div class="row wrapper">
            <div class="col-sm-8">
                <form class="form-horizontal" method="get"
                      action="{{ admin_action('Business\OrganizationalUserManagementController@userList',[$org_user,$dept_code,$agent_user]) }}">
                    <div class="row">
                        <div class="col-sm-4">
                            <div class="form-group">
                                <label class="control-label col-sm-4">姓名:</label>
                                <div class="col-sm-8">
                                    <input class="form-control" type="text" placeholder="欲查询的用户名" name="name"
                                           value="{{$query['name']}}"/>
                                </div>
                            </div>
                        </div>
                        <div class="col-sm-4">
                            <div class="form-group">
                                <label class="control-label col-sm-4">用户名:</label>
                                <div class="col-sm-8">
                                    <input class="form-control" type="text" placeholder="欲查询的用户名" name="username"
                                           value="{{$query['username']}}"/>
                                </div>
                            </div>
                        </div>
                        <div class="col-sm-1 text-left">
            <span class="input-group-btn">
              <button class="btn btn-sm btn-default" type="submit">查询</button>
            </span>
                        </div>
                    </div>
                </form>
            </div>
            <div class="col-sm-4 text-right text-center-xs">
                @accredit('web.navigations.create')
                <a class="btn m-b-xs btn-sm btn-default btn-addon"
                   href="{{ admin_action('Business\OrganizationalUserManagementController@create') }}">
                    <i class="fa fa-plus"></i>添加下属成员
                </a>
                @endaccredit
            </div>
        </div>
        <div class="table-responsive">
            <table class="table table-striped b-t b-light">
                <thead>
                <tr>
                    <th>用户ID</th>
                    <th>姓名</th>
                    <th>用户名</th>
                    <th>用户角色</th>
                    <th>创建时间</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                @forelse ($userInfos as $userInfo)
                    <tr>
                        <td>{{ $userInfo->user_id }}</td>
                        <td>{{ $userInfo->name??'--' }}</td>
                        <td>{{ $userInfo->user->username??'--' }}</td>
                        <td>{{ ($userInfo->user->hasRole('Agent')?'经纪人':'').' '.($userInfo->user->hasRole('Loaner')?'融资人':'').' '.($userInfo->user->hasRole('User')?'投资人':'') }}</td>
                        <td>{{ $userInfo->user->created_at }}</td>
                        <td>
                            <a class="btn btn-xs btn-danger"
                               href="{{ admin_action('Business\OrganizationalUserManagementController@changeAgent', [$org_user,$dept_code,$agent_user,$userInfo->user_id]) }}"
                               data-toggle="tooltip" title="变更用户经纪人">
                                <i class="fa fa-user"></i>
                            </a>
                        </td>
                    </tr>
                @empty
                    <tr>
                        <td colspan="3" class="text-center">没有找到用户记录</td>
                    </tr>
                @endforelse
                </tbody>
            </table>
        </div>
        <div class="panel-footer">
            <div class="row">
                <div class="col-sm-12 text-right text-center-xs">
                    {!! $links !!}
                </div>
            </div>
        </div>
    </div>
@endsection